import React, { useContext } from "react";
import { Modal } from "antd";
// import { context } from '@/hooks/useContext'

/**
 * 弹窗不是用于表单提交类型需要自定义传入按钮组
 * @param footerMenu 
 * @returns 
 */

export const ModalDialog = (props) => {
  const {
    isModal,
    formRef,
    handleModalCancel,
    contentSlot,
    width,
    okText = "确定",
    cancelText = "取消",
    footerMenu = [],
  } = props;

  const handleCancel = () => {
    handleModalCancel({ isModalStatus: false, isModalTitle: "" });
  };
  return !footerMenu.length ? (
    <Modal
      title={isModal.isModalTitle}
      open={isModal.isModalStatus}
      maskClosable={false}
      width={width}
      cancelText={cancelText}
      okText={okText}
      onOk={(e) => formRef?.current?.submit()}
      onCancel={handleCancel}
    >
      {contentSlot}
    </Modal>
  ) : (
    <Modal
      title={isModal.isModalTitle}
      open={isModal.isModalStatus}
      maskClosable={false}
      width={width}
      cancelText="取消"
      okText="确定"
      onOk={(e) => formRef?.current?.submit()}
      onCancel={handleCancel}
      footer={footerMenu}
    >
      {contentSlot}
    </Modal>
  );
};

export default ModalDialog;
